{% extends "mp_base.html"%}
{% load commonFilters %}
{% load i18n %}

{% comment %}
copyright (c) 2009, paketka@gmail.com et. al
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:

	* Redistributions of source code must retain the above copyright notice,
	  this list of conditions and the following disclaimer.

	* Redistributions in binary form must reproduce the above copyright notice,
	  this list of conditions and the following disclaimer in the documentation
	  and/or other materials provided with the distribution.

	* Neither the name of the <ORGANIZATION> nor the names of its contributors
	  may be used to endorse or promote products derived from this software
 	  without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
{% endcomment %}

{% block keywords %}
poslanec, {{ mp.name }} {{ mp.surname }}, poslankyně, zvolené období, detail, {{ mp.term.getStart }} - {{ mp.term.getEnd }},
funkční období, jak jsem hlasoval
{% endblock %}
{% block css-links %}
	<link rel="stylesheet" type="text/css" href="{{ MEDIA_URL }}/css/ui.jqgrid.css" />
{% endblock %}

{% block js-links %}
	<script type="text/javascript" src="{{ MEDIA_URL }}/js/jquery.scrollTo-min.js"></script>
	<script type="text/javascript" src="{{ MEDIA_URL }}/js/js/jqModal.js"></script>
	<script type="text/javascript" src="{{ MEDIA_URL }}/js/js/jqDnR.js"></script>
	<script type="text/javascript" src="{{ MEDIA_URL }}/js/js/jquery.jqGrid.js"></script>
{% endblock %}

{% block javascript-head %}
{{ block.super }}
function createGrid(tableId, pagerId, url, caption)
{
	$(tableId).jqGrid({
				url: url,
				datatype: 'json',
				colNames: [	"{% trans "Číslo hlasování" %}",
							"{% trans "Název hlasování" %}",
							"{% trans "Výsledek" %}",
							"{% trans "Loajální" %}"
					],
				colModel :[
					{ name: "pollNo", index: "pollNo", width: 80, jsonmap: "pollNo", sortable: false },
					{ name: "title", index: "title", width: 200, jsonmap: "title", sortable: false },
					{ name: "result", index: "result", width: 120, jsonmap:"result", sortable: false },
					{ name: "loyal", index: "loyal", width: 80, jsonmap: "loyal", sortable: false}
				], 
				pager: $(pagerId),
				jsonReader: {
					root: "rows",
					id: "pk",
					page: "page",
					total: "total",
					records: "records",
					repeatitems: false
				},
				sortname:"start",
				sortorder:"desc",
				rowNum:10,
				rowList:[10,15,20],
				viewrecords:true,
				caption: caption,
				width:640,
				toolbar: [true,'top']
	});
	$(tableId).navGrid(pagerId,{edit:false,add:false,del:false});
}

function meetingPickerSelect(dateText)
{
	$.scrollTo('#pollDate', 800);
	{% url json.views.get_date_data_json mp.slug mp.term.id currentDate.year currentDate.month currentDate.day as baseUrl %}
	var baseUrl = '{{ baseUrl }}'.replace(/\/\d{4}\/\d{1,2}\/\d{1,2}\//g,'');
	switchDate(baseUrl + '/' + dateText, '/' + dateText, false);
}

{% if prevDate %}
	var prevDate = '{{ prevDate|date:"/Y/m/d/" }}';
{% else %}
	var prevDate = null;
{% endif %}

{% if nextDate %}
	var nextDate = '{{ nextDate|date:"/Y/m/d/" }}';
{% else %}
	var nextDate = null;
{% endif %}

{% if currentDate %}
	var currentDate = '{{ currentDate|date:"/Y/m/d/" }}';
{% else %}
	var currentDate = null;
{% endif %}

var loyalChartsTermIndex = 0;
var loyalChartsDayIndex = 0;
var chartArrayLength = {{ mships|length }} + {{ parties|length }};
var loyalChartsTerm = [
	{% for i in mships %}
		{% if forloop.last %}
			'{% url json.views.get_loyal_pie_term mp.slug,i.group.id,mp.term.id %}'
		{% else %}
			'{% url json.views.get_loyal_pie_term mp.slug,i.group.id,mp.term.id %}',
		{% endif %}
	{% endfor %}
	{% for group in parties %}
		{% comment %}
			we need to to add a ',' since list continues with parties now
		{% endcomment %}
		{% if forloop.first %}
			,
		{% endif %}
		{% if forloop.last %}
			'{% url json.views.get_loyal_pie_term mp.slug,group.id,mp.term.id %}'
		{% else %}
			'{% url json.views.get_loyal_pie_term mp.slug,group.id,mp.term.id %}',
		{% endif %}
	{% endfor %}
];

var loyalChartsDay = [
	{% for i in mships %}
		{% if forloop.last %}
			'{% url json.views.get_loyal_pie_day mp.slug,i.group.id,currentDate.year,currentDate.month,currentDate.day %}'
		{% else %}
			'{% url json.views.get_loyal_pie_day mp.slug,i.group.id,currentDate.year,currentDate.month,currentDate.day %}',
		{% endif %}
	{% endfor %}
	{% for group in parties %}
		{% comment %}
			we need to to add a ',' since list continues with parties now
		{% endcomment %}
		{% if forloop.first %}
			,
		{% endif %}
		{% if forloop.last %}
			'{% url json.views.get_loyal_pie_day mp.slug,group.id,currentDate.year,currentDate.month,currentDate.day %}'
		{% else %}
			'{% url json.views.get_loyal_pie_day mp.slug,group.id,currentDate.year,currentDate.month,currentDate.day %}',
		{% endif %}
	{% endfor %}
];

var linkParams = [];

function updateCtrlLink()
{
	var baseUrl = $('.ctrl-link').attr('href');
	var tmpUrl = '';

	for (key in linkParams) {
		tmpUrl += key + '=' + linkParams[key] + '&';
	}

	if (tmpUrl != '') {
		baseUrl = baseUrl.replace(/\?.*$/g,'');
		baseUrl += '?' + tmpUrl.replace(/&$/g, '');
		$('.ctrl-link').attr('href', baseUrl);
	}
}

{% comment %} 
Changes loyality chart for term
{% endcomment %}
function chartTermClick(where)
{
	{% if mships|length_is:"0" %}
		return;
	{% else %}
		if (where == 'prev') {
			if (loyalChartsTermIndex == 0) {
				loyalChartsTermIndex = chartArrayLength;
			}
			loyalChartsTermIndex = loyalChartsTermIndex - 1;
		}
		else if (where == 'next') {
			loyalChartsTermIndex = (loyalChartsTermIndex + 1) % chartArrayLength;
		}

		if (loyalChartsTerm[loyalChartsTermIndex].charAt(0) == "<") {
			$("#loyalChartTerm").html(loyalChartsTerm[loyalChartsTermIndex]);
		}
		else {
			$("#loyalChartTerm").html('<img src="{{ MEDIA_URL }}/images/wait.gif"/>')
			$.ajax({
					url : loyalChartsTerm[loyalChartsTermIndex],
					async : true,
					dataType : 'json',
					success : function(data) {
							$("#loyalChartTerm").html(data);
							loyalChartsTerm[loyalChartsTermIndex] = data;
					},
					error : function(XMLHttpRequest, textStatus, errorThrown) {
							$("#loyalChartTerm").html('<img src="{{ MEDIA_URL }}/images/error.gif"/>');
					}
			});
		}
		$("#groupsTerm")[0].selectedIndex = loyalChartsTermIndex;
	{% endif %}
}

{% comment %}
Changes loyality chart for day
{% endcomment %}
function chartDayClick(where)
{
	{% if mships|length_is:"0" %}
		return;
	{% else %}
		if (where == 'prev') {
			if (loyalChartsDayIndex == 0) {
				loyalChartsDayIndex = chartArrayLength;
			}
			loyalChartsDayIndex = loyalChartsDayIndex - 1;
		}
		else if (where == 'next') {
			loyalChartsDayIndex = (loyalChartsDayIndex + 1) % chartArrayLength;
		}

		if (loyalChartsDay[loyalChartsDayIndex].charAt(0) == "<") {
			$("#loyalChartDay").html(loyalChartsDay[loyalChartsDayIndex]);
		}
		else {
			var baseUrl = loyalChartsDay[loyalChartsDayIndex].replace(/\/\d{4}\/\d{1,2}\/\d{1,2}\//g,'');
			baseUrl += currentDate;
			$("#loyalChartDay").html('<img src="{{ MEDIA_URL }}/images/wait.gif"/>');
			$.ajax({
					url : baseUrl,
					async : true,
					dataType : 'json',
					success : function(data) {
							$("#loyalChartDay").html(data);
					},
					error : function(XMLHttpRequest, textStatus, errorThrown) {
							$("#loyalChartDay").html('<img src="{{ MEDIA_URL }}/images/error.gif"/>');
					}
			});
		}
		
		$("#groupsDay")[0].selectedIndex = loyalChartsDayIndex;
	{% endif %}
}

{% comment %}
Changes loyality chart for term or day (depending on argument)
{% endcomment %}
function groupChanged(elemId)
{
	var baseUrl = '';

	if (elemId == 'groupsDay') {
		divId = '#loyalChartDay';
		newIndex = $("#groupsDay")[0].selectedIndex;
		loyalChartsDayIndex = newIndex;
		workingArray = loyalChartsDay;
		baseUrl = workingArray[newIndex].replace(/\/\d{4}\/\d{1,2}\/\d{1,2}\//g,'');
		baseUrl += currentDate;
		linkParams['peerGroupIndex'] = newIndex;
	}
	else if (elemId == 'groupsTerm') {
		divId = '#loyalChartTerm';
		newIndex = $("#groupsTerm")[0].selectedIndex;
		loyalChartsTermIndex = newIndex;
		workingArray = loyalChartsTerm;
		baseUrl = workingArray[newIndex];
		linkParams['peerTermGroupIndex'] = newIndex;
	}
	else
		return;
	
	updateCtrlLink();

	if (workingArray[newIndex].charAt(0) == "<") {
		$(divId).html(workingArray[newIndex]);
	}
	else {
		$(divId).html('<img src="{{ MEDIA_URL }}/images/wait.gif"/>');
		$.ajax({
				url : baseUrl,
				async : true,
				dataType : 'json',
				success : function(data) {
						$(divId).html(data);
						workingArray[newIndex] = data;
				},
				error : function(XMLHttpRequest, textStatus, errorThrown) {
						$(divId).html('<img src="{{ MEDIA_URL }}/images/error.gif"/>');
				}
		});
	}
}

var filterEnabled = false;

function getUrl(urlStr)
{% comment %}
it checks if 'Proceduralni hlasovani' polls should be removed from grids,
if so, it then appends an option ?filterProcedural=1 to url.
{% endcomment %}
{
	var retVal = "";

	if (filterEnabled)
		retVal = urlStr + '?filterProcedural=1';
	else
		retVal = urlStr.replace(/\?filterProcedural=1/g,'');

	return retVal
}

function filterProcedural(id)
{% comment %}
This is callback, that handles checkbox change events
{% endcomment %}
{
	if (filterEnabled) {
		filterEnabled = false;
	}
	else {
		filterEnabled = true;
	}

	grids = [];
	grids[0] = '#aye';
	grids[1] = '#nay';
	grids[2] = '#refrain';
	grids[3] = '#absences';

	{% comment %}
	We are going to retrieve Data URL for each particular grid
	{% endcomment %}
	for (i in grids) {
		$(grids[i]).setGridParam({
			url : getUrl(	$(grids[i]).getGridParam('url'))
		}).trigger("reloadGrid");
	}
}

function switchDate(dateUrl, date, updateMeetingPicker)
{
	{% comment %}
	dateUrl contains AJAX URL to query for a new pair of previous date and
	next date.
	
	the date is date we are switching to.

	{% endcomment %}

	$("#pollDate").text(date.replace(/\//g, ' '));
	
	{% comment %}
	This looks a bit strange at first glance, but it's fairly obvious.
	We need to get AJAX URL for data grids to fetch new data. To get these
	URLs we need to:
		get URL json view for particular data, we are using currentDate,
		to get such URL

		once we have the json view URL we need to adjust it for desired day,
		we strip the date parameters i.e. the URL below
			/json/blaBla/josef_novak/2008/7/12/
		will become
			/json/blaBla/josef_novak/

		then we append the desired date parameter to it.
	{% endcomment %}
	{% url json.views.get_aye mp.slug currentDate.year currentDate.month currentDate.day as gridBaseUrl %}
	var gridUrl = '{{ gridBaseUrl }}'.replace(/\/\d{4}\/\d{1,2}\/\d{1,2}\//g,'');
	$("#aye").setGridParam({ url: getUrl(gridUrl + date) }).trigger("reloadGrid");

	{% url json.views.get_nay mp.slug currentDate.year currentDate.month currentDate.day as gridBaseUrl %}
	var gridUrl = '{{ gridBaseUrl }}'.replace(/\/\d{4}\/\d{1,2}\/\d{1,2}\//g,'');
	$("#nay").setGridParam({ url: getUrl(gridUrl + date) }).trigger("reloadGrid");

	{% url json.views.get_refrains mp.slug currentDate.year currentDate.month currentDate.day as gridBaseUrl %}
	var gridUrl = '{{ gridBaseUrl }}'.replace(/\/\d{4}\/\d{1,2}\/\d{1,2}\//g,'');
	$("#refrain").setGridParam({ url: getUrl(gridUrl + date) }).trigger("reloadGrid");

	{% url json.views.get_absences mp.slug currentDate.year currentDate.month currentDate.day as gridBaseUrl %}
	var gridUrl = '{{ gridBaseUrl }}'.replace(/\/\d{4}\/\d{1,2}\/\d{1,2}\//g,'');
	$("#absences").setGridParam({ url: getUrl(gridUrl + date) }).trigger("reloadGrid");

	if (updateMeetingPicker) {
		var dateParts = date.split('/');
		var d = new Date(	parseInt(dateParts[1]),
							parseInt(dateParts[2]) - 1,	/* January is month 0 */
							parseInt(dateParts[3])
						);
		$("#meetingPicker").datepicker('setDate', d);
	}

	var baseUrl = $('.ctrl-link').attr('href').replace(/\/\d{4}\/\d{1,2}\/\d{1,2}\//g,'');
	$('.ctrl-link').attr('href', baseUrl + date);
	updateCtrlLink();

	$.ajax({
			url : dateUrl,
			async : true,
			dataType : 'json',
			success : function(data) {
					prevDate = data.prevDate;
					nextDate = data.nextDate;
					currentDate = date;

					$("#totalDayPolls").text(data.totalDayPolls);
					$("#acceptedProposals").text(data.acceptedProposals);
					$("#refusedProposals").text(data.refusedProposals);
					$("#mpAbsences").text(data.mpAbsences);				
					$("#mpAye").text(data.mpAye);
					$("#mpNay").text(data.mpNay);
					$("#mpRefrains").text(data.mpRefrains);
					$("#loyalDayChart").html(data.loyalDayChart);
					$("#mpDayStatChart").html(data.mpDayStatChart);

					if (nextDate == null) {
						$("#nextDay").hide();
					}
					else {
						$("#nextDate").text(nextDate.replace(/\//g, ' '));
						$("#nextDay").show();
					}

					if (prevDate == null) {
						$("#prevDay").hide();
					}
					else {
						$("#prevDate").text(prevDate.replace(/\//g, ' '));
						$("#prevDay").show();
					}
					
					{% comment %}
					 We need to reset pies for particular day. We simply do:
					 setting index to the second chart url,
					 pretending the 'prev' button was pressed -> index will move
					 to reference the first position.
					{% endcomment %}
					loyalChartsDayIndex = 1;
					chartDayClick('prev');
			},
			error : function(XMLHttpRequest, textStatus, errorThrown) {
					$("#loyalDayChart").html('<img src="{{ MEDIA_URL }}/images/error.gif"/>');
					$("#mpDayStatChart").html('<img src="{{ MEDIA_URL }}/images/error.gif"/>');
			}
	});
}

function meetingPickerSelect(dateText)
{
	$.scrollTo('#pollDate', 800);
	{% url json.views.get_date_data_json mp.slug mp.term.id currentDate.year currentDate.month currentDate.day as baseUrl %}
	var baseUrl = '{{ baseUrl }}'.replace(/\/\d{4}\/\d{1,2}\/\d{1,2}\//g,'');
	switchDate(baseUrl + '/' + dateText, '/' + dateText, false);
}

$(document).ready(function(){
	createGrid(
		"#aye",
		"#aye-pager",
		getUrl("{% url json.views.get_aye mp.slug currentDate.year currentDate.month currentDate.day %}"),
		"{% trans "Návrhy poslancem podpořené" %}"
	);
	
	createGrid(
		"#nay",
		"#nay-pager",
		getUrl("{% url json.views.get_nay mp.slug currentDate.year currentDate.month currentDate.day %}"),
		"{% trans "Návrhy poslancem zamítnuté" %}"
	);

	createGrid(
		"#refrain",
		"#refrain-pager",
		getUrl("{% url json.views.get_refrains mp.slug currentDate.year currentDate.month currentDate.day %}"),
		"{% trans "Poslanec se zdržel hlasování" %}"
	);

	createGrid(
		"#absences",
		"#absences-pager",
		getUrl("{% url json.views.get_absences mp.slug currentDate.year currentDate.month currentDate.day %}"),
		"{% trans "Hlasování, kdy poslanec nebyl přítomen" %}"
	);

	{% if peerGroupIndex %}
		$("#groupsDay")[0].selectedIndex = {{ peerGroupIndex }};
		groupChanged("groupsDay");
		$.scrollTo("#loyalChartTerm", 800);
	{% endif %}

	{% if peerTermGroupIndex %}
		$("#groupsTerm")[0].selectedIndex = {{ peerTermGroupIndex }};
		groupChanged("groupsTerm");
		$.scrollTo("#loyalChartTerm", 800);
	{% endif %}

});

{% endblock %}

{% block left-sidebar %}
	<div class="ui-widget">
		<div class="ui-widget-header">
			<h1>{% trans "Kalendář hlasování" %}</h1>
		</div>
		<div class="ui-widget-content">
			<div class="container">
				{% url json.views.get_meetings_in_month currentDate.year currentDate.month as events %}
				{% url psp.views.show_day_polls currentDate.year currentDate.month currentDate.day as eventDetails %}
				{% datepicker "meetingPicker" events eventDetails currentDate.year currentDate.month dateStart dateEnd onSelect="meetingPickerSelect" %}
			</div>
		</div>
	</div>
	
	<div class="ui-widget">
		<div class="ui-widget-header">
			<h1>{% trans "Období" %}</h1>
		</div>
		<div class="ui-widget-content">
		<div class="container">
			<ul>
			{% for t in termLinks %}
				<li>{{ t|safe }}</li>
			{% endfor %}
			</ul>
		</div>
		</div>
	</div>
{% endblock %}

{% block mpContent %}

<div class="ui-widget">
	<div class="ui-widget-header">
		<h2>{% trans "Členství v parlamentních organizacích" %}</h2>
	</div>
	<div class="ui-widget-content">
	<p>
		{% trans "V období" %} {{ mp.term.getStart }} - {{ mp.term.getEnd }} 
		{% trans "zasedám mimojiné i v těchto parlamentních skupinách a organizacích:" %}
	</p>
	{% for i in mships %}
		<div class="left">
			<a href="{% url psp.views.show_group i.group.slug %}"> {{i.group.name}}</a>
		</div>
		<div class="right">
			 [ {{ i.start|date:"Y m d" }} - {% if i.end %} {{ i.end|date:"Y m d" }} {% else %} {% now "Y m d" %} {% endif %}]
		</div>
		<div class="clear"></div>
		<p></p>
	{% endfor %}
	</ul>
	</div>
</div>

<div class="ui-widget">
	<div class="ui-widget-header">
		<h2>{% trans "Má absence a loajalita za celé období" %}</h2>
	</div>
	<div class="ui-widget-content">
		<div class="left">
			<p>
				{% trans "Již dobře známý koláček vpravo znázorňuje mou absenci v období" %}
				{{ mp.term.getStart }} - {{ mp.term.getEnd }}.
			</p>
		</div>
		<div class="right">
			{{ mpAbsencesPie.img|safe }}
		</div>
		<div class="clear"><p></p></div>
		<div class="left">
			<div id="loyalChartTerm">
				{{ loyalChart.img|safe }}
			</div>
			<div id="loyalChartTermControl">
			<div class="left-1-third">
				<p></p>
			{% comment %}
				<a href="#void" onClick="chartTermClick('prev')" id="prevLoyalChartTerm">
					<span class="ui-icon ui-icon-arrowthick-1-w" id="prevLoyalChartTermIcon"></span>
					{% trans "Předchozí skupina" %}
				</a>
			{% endcomment %}
			</div>
			<div class="center groupSelect">
				<select name="groupsTerm" id="groupsTerm" onChange="groupChanged(this.id)">
				{% for m in mships %}
					{% ifequal m.group.type "KLUB" %}
						<option value="{{ m.group.id }}">{{ m.group.getPartyName }}</option>
					{% else %}
						<option value="{{ m.group.id }}">{{ m.group.name|truncatewords:3 }}</option>
					{% endifequal %}
				{% endfor %}
				{% for group in parties %}
					<option value="{{ group.id }}">{{ group.getPartyName }}</option>
				{% endfor %}
				</select>
			</div>
			<div class="left-1-third">
				<p></p>
			{% comment %}
				<a href="#void" onClick="chartTermClick('next')" id="nextLoyalChartTerm">
					<span class="ui-icon ui-icon-arrowthick-1-e" id="nextLoyalChartTermIcon"></span>
					{% trans "Další skupina" %}
				</a>
			{% endcomment %}
			</div>
			</div>
		</div>
		<div class="right">
			<p> {% blocktrans %}
				Graf vlevo znázorňuje <a
				href="http://cs.wikipedia.org/wiki/Loajalita">loajalitu</a>
				poslance s danou skupinou (partajním klubem, komisí, výborem
				atp.). Koláč se počítá následujícím způsobem:
				<ol>
					<li>
						Pro všechna hlasování v daném období (celé volební
						období nebo jeden den) se zjistí jak hlasovala zvolená
						skupina.
					</li>
					<li>
						Pro všechna hlasování v daném období (celé volební
						období, pouze jeden den atp.) se zjistí jak hlasoval daný
						poslanec (např. 
					{% endblocktrans %} {{ mp.name }} {{ mp.surname }}).
					{% blocktrans %}
					</li>
					<li>
						Oba výběry získané v krocích (1) a (2) se porovnají a
						zjistí se kolikrát se výsledek hlasování pro celou
						skupinu liší od hlasování daného poslance.
					</li>
				</ol>
				{% endblocktrans %}
			</p>
		</div>
		<div class="clear"></div>
		<p> {% blocktrans %}
			Výsledek hlasování celé skupiny je určen na základě většiny hlasů
			odevzdaných jejímy členy.  Má-li skupna 10 členů a 6 hlasuje pro,
			je výsledek pro.  Dojde-li k rovnosti hlasů (5 pro, 5 proti) je
			výsledek pro celou skupinu proti. Naštěstí rovnost hlasů v rámci
			skupiny je příliš vzácný jev, aby se v konečném výsledku toto
			zjednodušení projevilo.
			{% endblocktrans %}
		</p>
		<p>
			<a href="{% url psp.views.show_mp_day mp.slug,currentDate.year,currentDate.month,currentDate.day %}" class="ctrl-link">link</a>
		</p>
	</div>
</div>

<div class="ui-widget">
	<div class="ui-widget-header">
		<h2>{% trans "Mé hlasování" %} <span id="pollDate">{{ currentDate|date:"Y m d" }}</span></h2>
	</div>
	<div class="ui-widget-content">

		<div class="left">
			<div id="mpDayStatChart">
				{{ mpDayStatChart.img|safe }}
			</div>
			<div id="dateNav">
				<script type="text/javascript">
					{% comment %}
						Same pattern we've already seen in switchDate() function
						
						Also don't forget to update meetingPicker with new date
						(the 'true' argument in switchDate()). 
					 {% endcomment %}
					{% url json.views.get_date_data_json mp.slug mp.term.id currentDate.year currentDate.month currentDate.day  as baseUrl %}
					var baseUrl = '{{ baseUrl }}'.replace(/\/\d{4}\/\d{1,2}\/\d{1,2}\//g,'');
				</script>
				<div class="left">
				{% if prevDate %}
					<a href="#void" onClick="switchDate(baseUrl  + prevDate, prevDate, true)" id="prevDay">
				{% else %}
					<a href="#void" onClick="switchDate(baseUrl  + prevDate, prevDate, true)" id="prevDay" class="slideDefaultHidden">
				{% endif %}
						<span class="ui-icon ui-icon-arrowthick-1-w" id="prevDayIcon"></span>
						<span id="prevDate">{{ prevDate|date:"Y m d" }}</span>
					</a>
				</div>
				<div class="right">
				{% if nextDate %}
					<a href="#void" onClick="switchDate(baseUrl + nextDate, nextDate, true)" id="nextDay">
				{% else %}
					<a href="#void" onClick="switchDate(baseUrl + nextDate, nextDate, true)" id="nextDay" class="slideDefaultHidden">
				{% endif %}
						<span class="ui-icon ui-icon-arrowthick-1-e" id="nextDayIcon"></span>
						<span id="nextDate">{{ nextDate|date:"Y m d" }}</span>
					</a>
				</div>
			</div>
			<div class="clear"></div>
		</div>
		<div class="right">
		<p> {% blocktrans %}
			Tento den proběhlo <span id="totalDayPolls">{{ totalDayPolls }}</span> hlasování.
			<span id="acceptedProposals">{{ acceptedProposals }}</span> návrhů bylo přijato, zatímco
			<span id="refusedProposals">{{ refusedProposals }}</span> jich bylo zamítnuto. Poslanec
			se nezúčastnil <span id="mpAbsences">{{ mpAbsences }}</span> hlasování. <span id="mpAye">
			{{ mpAye }}</span>x hlasoval pro, <span id="mpNay">{{ mpNay }}</span>x proti a <span id="mpRefrains"> 
			{{ mpRefrains }}</span>x se zdržel hlasování.
			{% endblocktrans %}
		</p>
		<p>
			<a href="{% url psp.views.show_mp_day mp.slug,currentDate.year,currentDate.month,currentDate.day %}" class="ctrl-link">link</a>
		</p>
		</div>
		<div class="clear"></div>
	</div>
</div>

<div class="ui-widget">
	<div class="ui-widget-header">
		<h2>{% trans "Má dení loajalita" %}</h2>
	</div>
	<div class="ui-widget-content">
		<div id="loyalChartDay">
			{{ loyalDayChart.img|safe }}
		</div>
		<div id="loyalChartDayControl">
			<div class="left-1-third">
			<p></p>
			</div>
			<div class="center groupSelect">
				<select name="groupsDay" id="groupsDay" onChange="groupChanged(this.id)">
				{% for m in mships %}
					{% ifequal m.group.type "KLUB" %}
						<option value="{{ m.group.id }}">{{ m.group.getPartyName }}</option>
					{% else %}
						<option value="{{ m.group.id }}">{{ m.group.name|truncatewords:3 }}</option>
					{% endifequal %}
				{% endfor %}
				{% for group in parties %}
					<option value="{{ group.id }}">{{ group.getPartyName }}</option>
				{% endfor %}
				</select>
			</div>
			<div class="left-1-third">
			<p>
				<a href="{% url psp.views.show_mp_day mp.slug,currentDate.year,currentDate.month,currentDate.day %}" class="ctrl-link">link</a>
			</p>
			</div>
			<div class="clear"></div>
		</div>
	</div>
</div>
<div class="ui-widget">
	<div class="ui-widget-header">
		<h2>{% trans "Detailní přehled" %}</h2>
	</div>
	<div class="ui-widget-content">
		<p>
		<input type="checkbox" id="filterProcedural" onclick="filterProcedural(this.checked)">
			{% trans "Skryj procedurální hlasování" %}  <br/> 
	</p>
	<table id="aye" class="scroll" cellpadding="0" cellspacing="0">
	</table>
	<div id="aye-pager" class="scroll" style="text-align:center;">
	</div>

	<table id="nay" class="scroll" cellpadding="0" cellspacing="0"> 
	</table>
	<div id="nay-pager" class="scroll" style="text-align:center;">
	</div>

	<table id="refrain" class="scroll" cellpadding="0" cellspacing="0"> 
	</table>
	<div id="refrain-pager" class="scroll" style="text-align:center;">
	</div>

	<table id="absences" class="scroll" cellpadding="0" cellspacing="0"> 
	</table>
	<div id="absences-pager" class="scroll" style="text-align:center;">
	</div>
	</div>
</div>
{% endblock %}

